var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var BundleConfig = require("AA_BundleConfig");
var AudioManager = require("AA_AudioManager");
var ResKeeper = require("AA_ResKeeper");
var Excel = require("AA_Excel");
var GameGlobalVariable = require("AA_GameGlobalVariable");
var BuffMag = require("AA_BuffMag");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_BulletDaBang = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.bulletId = 1;
    t.bangzi = null;
    t.pengzhuangti = null;
    t.attackfang = null;
    t.isbisha = false;
    t.isbaoji = false;
    t.nowbuffdata = null;
    t.ishave = false;
    t.leijitime = 0;
    t.jiangetime = 0;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.initDaBang = function (e) {
    this.attackfang = e;
    this.nowbuffdata = Excel.Excel.shuiguobuff(89);
    this.leijitime = 0;
    this.jiangetime = this.nowbuffdata.bufftime;
    this.bangzi.node.active = false;
  };
  _creator.prototype.getBiSha = function (e) {
    this.isbisha = BuffMag.BuffMgr.getLajiaoBiSha(this.attackfang, GameGlobalVariable.GameGlobalVariable.wukongbishabili);
    if (!this.isbisha) {
      var t = BuffMag.BuffMgr.getZhanShaBuff();
      t && e <= t.value[1] / 100 && Math.random() <= t.probability / 100 && (this.isbisha = true);
    }
    return this.isbisha;
  };
  _creator.prototype.getBulletAttack = function () {
    var e = BuffMag.BuffMgr.playAttackJiaCheng(this.attackfang, this.attackfang.sgattack, 1);
    var t = BuffMag.BuffMgr.getAttackBaoJi(this.attackfang);
    var o = this.attackfang.sgbaojilv + t.baojijilv;
    var n = this.attackfang.sgbaojia + t.baojijiacheng;
    Math.random() <= o && (e *= n);
    return e;
  };
  _creator.prototype.getNowMosterNode = function (e) {
    var t = GameGlobalVariable.GameGlobalVariable.mosterNode.children;
    var o = [];
    for (var n = 0; n < t.length; n++) {
      var i = t[n];
      var a = cc.Vec2.distance(i.getPosition(), this.node.getPosition());
      (a -= i.width / 2 + this.node.width / 2) <= e && o.push(i);
    }
    return o;
  };
  _creator.prototype.huiBangZi = function () {
    var e = this;
    this.bangzi.node.active = true;
    AudioManager.AudioMgr.playEffect("game/sound/gunzishanghai", false, BundleConfig.BundleNames.Game);
    this.bangzi.playAnimation("da", 1);
    cc.tween(this.pengzhuangti).to(.5, {
      angle: -360
    }).call(function () {
      e.pengzhuangti.angle = 0;
    }).start();
  };
  _creator.prototype.isFanWeiMoster = function () {
    if (this.getNowMosterNode(300).length > 0) {
      if (!this.ishave) {
        this.ishave = true;
        this.huiBangZi();
        this.leijitime = 0;
      }
    } else {
      this.ishave = false;
    }
  };
  _creator.prototype.onUpdate = function (e) {
    this.isFanWeiMoster();
    if (this.ishave) {
      this.leijitime += e;
      if (this.leijitime > this.jiangetime) {
        this.huiBangZi();
        this.leijitime = 0;
      }
    }
  };
  __decorate([_property()], _creator.prototype, "bulletId", undefined);
  __decorate([_property(dragonBones.ArmatureDisplay)], _creator.prototype, "bangzi", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "pengzhuangti", undefined);
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_UI_BulletDaBang;